package gengine.common.packets.client;

import gengine.common.misc.ClientInfo;
import gengine.common.packets.BasePacket;
import gengine.common.packets.PacketTypeEnum;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * User: Arseniy
 * Date: 21.12.11
 * Time: 8:54
 */
public class ClientInfoPacket extends BasePacket{
    protected ClientInfo clientInfo;

    public ClientInfoPacket(int clientId, ClientInfo clientInfo) {
        super(clientId);
        this.clientInfo = clientInfo;
    }

    public ClientInfoPacket() {
    }

    public ClientInfo getClientInfo() {return clientInfo;}

    @Override
    public PacketTypeEnum getPacketType() {
        return PacketTypeEnum.ClientInfoPacket;
    }

    @Override
    protected void readCore(ObjectInputStream stream) throws IOException {
        try {
            clientInfo = (ClientInfo) stream.readObject();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void writeCore(ObjectOutputStream stream) throws IOException {
        stream.writeObject(clientInfo);
    }
}
